﻿#region Copyright and License Notice
// Copyright (C)2010-2016 - Rob Levine and other contributors
// http://configgen.codeplex.com
// 
// This file is part of ConfigGen.
// 
// ConfigGen is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// ConfigGen is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License and 
// the GNU Lesser General Public License along with ConfigGen.  
// If not, see <http://www.gnu.org/licenses/>
#endregion

using System;
using System.IO;

namespace ConfigGen.Core.TokenHandling
{
    /// <summary>
    /// Interface implemented by the <see cref="TokenLocator"/> class.
    /// </summary>
    public interface ITokenLocator
    {
        /// <summary>
        /// Raised when a known token is encountered during processing.
        /// </summary>
        event EventHandler<TokenEventArgs> TokenUsed;

        /// <summary>
        /// Raised when an unrecognised token is encountered during processing.
        /// </summary>
        event EventHandler<TokenEventArgs> UnrecognisedToken;

        /// <summary>
        /// Locates tokens in the supplied input, calling the supplied callback each time a token is located. The callback return specifies 
        /// the replacement string for the token. The input, with the tokens having been replaced, is written to the supplied output.
        /// </summary>
        /// <param name="input">
        /// Input stream
        /// </param>
        /// <param name="output">
        /// Output stream
        /// </param>
        /// <param name="tokenStartDelimiter">
        /// The token start delimiter.
        /// </param>
        /// <param name="tokenEndDelimiter">
        /// The token end delimiter.
        /// </param>
        /// <param name="tokenLocatedCallback">
        /// Callback to be called when a token is located, whose argument is the token, and whose return value 
        /// is the token replacement string.
        /// </param>
        void LocateTokens(TextReader input, TextWriter output, string tokenStartDelimiter, string tokenEndDelimiter, Func<string, string> tokenLocatedCallback);

    }
}
